package com.cdwh.joylife.ui.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.LinearLayout;

import com.cdwh.joylife.R;
import com.cdwh.joylife.ui.activity.SettingActivity;
import com.cdwh.joylife.ui.adapter.MeItemAdapter;
import com.cdwh.joylife.ui.adapter.OnItemClickLisenter;
import com.cdwh.joylife.ui.base.BaseFragment;
import com.cdwh.joylife.utils.UiUtils;
import com.cdwh.joylife.widget.TitleBar;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;
import de.hdodenhof.circleimageview.CircleImageView;
import qiu.niorgai.StatusBarCompat;

/**
 * Created by huxing on 2018/2/8.
 */

public class MeFragment extends BaseFragment {
    @BindView(R.id.titleBar)
    TitleBar titleBar;
    @BindView(R.id.btnSetting)
    ImageButton btnSetting;
    @BindView(R.id.btnShare)
    ImageButton btnShare;
    @BindView(R.id.ivHead)
    CircleImageView ivHead;
    @BindView(R.id.btnMyOrder)
    LinearLayout btnMyOrder;
    @BindView(R.id.recyclerViewOrder)
    RecyclerView recyclerViewOrder;
    @BindView(R.id.btnCollection)
    LinearLayout btnCollection;
    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;

    private static final int[] imageOrders = {R.mipmap.icon_dfk, R.mipmap.icon_dfh,
            R.mipmap.icon_dsh, R.mipmap.icon_dpj, R.mipmap.icon_sh};
    private static final int[] images = {R.mipmap.icon_qb, R.mipmap.icon_hy,
            R.mipmap.icon_jfsc, R.mipmap.icon_yhq, R.mipmap.icon_tjm};

    @Override
    public void onReceive(Object data) {

    }

    @Override
    public void onReceive(Object data, int type) {

    }

    @Override
    protected int getLayoutResId() {
        return R.layout.fragment_me;
    }

    @Override
    protected void initView(View layoutView) {
        titleBar.setPageBackIconGone(true);
        setGridLayoutManager(recyclerViewOrder, 5);
        setGridLayoutManager(recyclerView, 5);
        MeItemAdapter orderAdapter = new MeItemAdapter(imageOrders, UiUtils.getStringArray(R.array.me_orders));
        recyclerViewOrder.setAdapter(orderAdapter);
        orderAdapter.setOnItemClickLisenter(new OnItemClickLisenter() {
            @Override
            public void onClick(View v, int position) {

            }
        });
        MeItemAdapter adapter = new MeItemAdapter(images, UiUtils.getStringArray(R.array.me_items));
        recyclerView.setAdapter(adapter);
        adapter.setOnItemClickLisenter(new OnItemClickLisenter() {
            @Override
            public void onClick(View v, int position) {

            }
        });
    }

    @Override
    protected void loadData(int page) {

    }

    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
        if (!hidden) {
            StatusBarCompat.setStatusBarColor(getActivity(), UiUtils.getColor(R.color.colorPrimary));
        }
    }

    @OnClick({R.id.btnSetting, R.id.btnShare, R.id.btnMyOrder, R.id.btnCollection})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btnSetting:
                startActivity(new Intent(getActivity(), SettingActivity.class));
                break;
            case R.id.btnShare:
                break;
            case R.id.btnMyOrder:
                break;
            case R.id.btnCollection:
                break;
        }
    }
}
